package com.wetao.testrxjava;

import android.arch.lifecycle.Lifecycle;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

/*import com.uber.autodispose.AutoDispose;
import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider;*/

import java.util.concurrent.TimeUnit;

import io.reactivex.Observable;
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;

public class TestAutoDisposeActivity extends AppCompatActivity {
    private final String TAG = "TestAutoDisposeActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_auto_dispose);
    }

    @Override
    protected void onResume() {
        super.onResume();
        /*Observable.interval(1, TimeUnit.SECONDS)
                .doOnDispose(new Action() {
                    @Override
                    public void run() throws Exception {
                        Log.i(TAG, "========================= doOnDispose");

                    }
                })
                .as(AutoDispose.<Long>autoDisposable(AndroidLifecycleScopeProvider.from(TestAutoDisposeActivity.this, Lifecycle.Event.ON_DESTROY)))
                .subscribe(new Consumer<Long>() {
                    @Override
                    public void accept(Long aLong) throws Exception {
                        Log.i(TAG, "========================= subscribe--" + aLong);

                    }
                });*/
    }
}
